import { WeaTools,WeaLocaleProvider } from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

const { INPUT, SELECT, BROWSER } = WeaTools.types;
export const createCondition =(isshow=false,cycle,operatorSetType)=>{
    return [{
        items: [{
            conditionType: INPUT,
            domkey: ["appid"],
            label: getLabel(503168,'应用ID'),
            hide: true
        }, {
            conditionType: INPUT,
            domkey: ["appName"],
            label: getLabel(381923,'应用名称'),
            viewAttr: 1
        }, {
            conditionType: INPUT,
            domkey: ["name"],
            width: '280px',
            rules: 'required',
            label: getLabel('502853','任务名称'),
            viewAttr: 3
        }, {
            conditionType: BROWSER,
            domkey: ["rootOperator"],
            rules: operatorSetType == '1' ? 'required' : '',
            label: getLabel('', '上报节点操作者'),
            hide: operatorSetType != '1',
            width: '280px',
            browserConditionParam: {
                isSingle: false,
                replaceDatas: [],
                title: getLabel('502662', '选择操作者'),
                type: "17"
            },
            viewAttr: 3
        }, {
            conditionType: SELECT,
            domkey: ["cycle"],
            rules: 'required',
            label: getLabel(503316,'周期设置'),
            hide:true,
            options: [{
                key: "0",
                showname: getLabel(83519,'无'),
                selected: true,
            }, {
                key: "1",
                showname: getLabel(26577,'年'),
            }, {
                key: "2",
                showname: getLabel(33452,'月'),
            }, {
                key: "3",
                showname: getLabel(1926,'周'),
            }, {
                key: "4",
                showname: getLabel(390,'日'),
            }],
            detailtype: 3,
            viewAttr: 3
        }, {
            conditionType: "datepicker",
            domkey: ["taskDate"],
            value:new Date,
            startValue:new Date,
            rules: cycle==1 ? 'required' :"",
            label: getLabel(385638,'执行日期'),
            hide: cycle!=1
        }, {
            conditionType: SELECT,
            domkey: ["taskDay"],
            value:new Date,
            rules: cycle==2 ? 'required' :"",
            label: getLabel(385638,'执行日期'),
            hide: cycle!=2,
            options: res
            ,detailtype: 1,
        }, {
            conditionType: SELECT,
            domkey: ["taskWeek"],
            rules: cycle==3 ? 'required' :"",
            label: getLabel(18518,'星期'),
            hide: cycle!=3,
            options: [ {
                key: "2",
                showname: '一',
            }, {
                key: "3",
                showname: '二',
            }, {
                key: "4",
                showname: '三',
            }, {
                key: "5",
                showname: '四',
            }, {
                key: "6",
                showname: '五',
            }, {
                key: "7",
                showname: '六',
            }, {
                key: "1",
                showname: '日',
            }],detailtype: 3,
        }, {
            conditionType: "timepicker",
            domkey: ["taskTime"],
            minuteStep:1,
            value:'09:00' ,
            rules:isshow ? 'required' :"",
            label: getLabel(385636,'执行时间'),
            hide: isshow
        }],
        defaultshow: true
    }]
}
export default [{
    items: [{
        conditionType: INPUT,
        domkey: ["appid"],
        label: getLabel(503168,'应用ID'),
        hide: true
    }, {
        conditionType: INPUT,
        domkey: ["appName"],
        label: getLabel(381923,'应用名称'),
        viewAttr: 1
    }, {
        conditionType: INPUT,
        domkey: ["name"],
        rules: 'required',
        label: getLabel('502853','任务名称'),
        viewAttr: 3
    }, {
        conditionType: SELECT,
        domkey: ["cycle"],
        rules: 'required',
        label: getLabel(503316,'周期设置'),
        options: [{
            key: "0",
            showname: getLabel(83519,'无'),
            selected: true,
        }, {
            key: "1",
            showname: getLabel(26577,'年'),
        }, {
            key: "2",
            showname: getLabel(33452,'月'),
        }, {
            key: "3",
            showname: getLabel(1926,'周'),
        }, {
            key: "4",
            showname: getLabel(390,'日'),
        }],
        detailtype: 3,
        viewAttr: 3
    }, {
        conditionType: "datepicker",
        domkey: ["taskDate"],
        value:new Date,
        startValue:new Date,
        rules: 'required',
        label: getLabel(503317,'基准日期'),
        hide: 0
    }, {
        conditionType: "timepicker",
        domkey: ["taskTime"],
        minuteStep:30,
        value:'09:00' ,
        rules: 'required',
        label:  getLabel(503317,'基准日期'),
        hide: 0
    }],
    defaultshow: true
}]
var res = [];

export const createDay =()=> {
    for(var i = 1; i<=31 ; i++) {
        var selectMap={
            key:i,
            showname:i+getLabel(390,'日')
        };
        res.push(selectMap);
        
    }
}
